<!DOCTYPE html>

<html class="app-ui">

	<head>
		<!-- Meta -->
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />

		<!-- Document title -->
		<title>万邦-云阅卷</title>

		<meta name="description" content="AppUI - Admin Dashboard Template & UI Framework" />
		<meta name="author" content="rustheme" />
		<meta name="robots" content="noindex, nofollow" />

		<!-- Favicons -->
		<link rel="apple-touch-icon" href="assets/img/favicons/apple-touch-icon.png" />
		<link rel="icon" href="assets/img/favicons/favicon.ico" />

		<!-- Google fonts -->
		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,900%7CRoboto+Slab:300,400%7CRoboto+Mono:400" />

		<!-- Page JS Plugins CSS -->
		<link rel="stylesheet" href="assets/js/plugins/datatables/jquery.dataTables.min.css" />

		<!-- AppUI CSS stylesheets -->
		<link rel="stylesheet" id="css-font-awesome" href="assets/css/font-awesome.css" />
		<link rel="stylesheet" id="css-ionicons" href="assets/css/ionicons.css" />
		<link rel="stylesheet" id="css-bootstrap" href="assets/css/bootstrap.css" />
		<link rel="stylesheet" id="css-app" href="assets/css/app.css" />
		<link rel="stylesheet" id="css-app-custom" href="assets/css/app-custom.css" />
		<!-- End Stylesheets -->
	</head>

	<body class="app-ui layout-has-drawer layout-has-fixed-header">
		<div class="app-layout-canvas">
			<div class="app-layout-container">

				<!-- Drawer -->
				<aside class="app-layout-drawer">

					<!-- Drawer scroll area -->
					<div class="app-layout-drawer-scroll">
						<!-- Drawer logo -->
						<div id="logo" class="drawer-header">
							<a href="index.html">
								<h4 style=" text-align:center">云阅卷</h4>
							</a>
						</div>

						<!-- Drawer navigation -->
						<nav class="drawer-main">
							<ul class="nav nav-drawer">

								<li class="nav-item nav-drawer-header">菜单导航</li>

								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="ion-ios-calculator-outline"></i>考试管理</a>
									<ul class="nav nav-subnav">

										<li>
											<a href="examList.html">考试列表</a>
										</li>

										<li>
											<a href="createExam.html">创建考试</a>
										</li>
									</ul>
								</li>

								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="ion-ios-compose-outline"></i> 在线阅卷</a>
									<ul class="nav nav-subnav">

										<li>
											<a href="examSetting.html">阅卷设置</a>
										</li>

										<li>
											<a href="examPapers.html">我要阅卷</a>
										</li>

										<li>
											<a href="examProblemPapers.html">问题卷处理</a>
										</li>
										<li>
											<a href="examProgress.html">进度监控</a>
										</li>

										<li>
											<a href="examQuality.html">质量抽查</a>
										</li>

									</ul>
								</li>


								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="ion-ios-list-outline"></i> 成绩管理</a>
									<ul class="nav nav-subnav">

										<li>
											<a href="examReport.html">考试成绩单</a>
										</li>

										<li>
											<a href="examSubReport.html">单科试题得分表</a>
										</li>

										<li>
											<a href="gradeAnalyze.html">年纪成绩分析</a>
										</li>

										<li>
											<a href="classAnalyze.html">班级成绩分析</a>
										</li>

									</ul>
								</li>

								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="ion-ios-browsers-outline"></i> 教师讲卷</a>
									<ul class="nav nav-subnav">

										<li>
											<a href="scoreAndPapers.html">成绩与答卷</a>
										</li>

										<li>
											<a href="highScoreComposition.html">高分作文</a>
										</li>

										<li>
											<a href="topicScore.html">试题得分情况</a>
										</li>

										<li>
											<a href="subAnalyzeReport.html">学科分析报表</a>
										</li>
									</ul>
								</li>

								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="ion-social-javascript-outline"></i> 用户中心</a>
									<ul class="nav nav-subnav">

										<li>
											<a href="schoolManager.html">学校管理</a>
										</li>

										<li>
											<a href="subManager.html">学科管理</a>
										</li>

										<li>
											<a href="gradeManager.html">年级管理</a>
										</li>

										<li>
											<a href="gradeAndSubManager.html">年级与学科关系维护</a>
										</li>

										<li>
											<a href="teaManager.html">教师管理</a>
										</li>

										<li>
											<a href="classManager.html">班级管理</a>
										</li>

										<li>
											<a href="stuManager.html">学生管理</a>
										</li>

										<li>
											<a href="subAdnClassAnager.html">学科与班级关系维护</a>
										</li>
									</ul>
								</li>

							</ul>
						</nav>
						<!-- End drawer navigation -->

						<div class="drawer-footer">
							<p class="copyright">Copyright &copy; 2020.北京万邦易嵌科技有限公司.<a target="_blank" href="http://www.wanbangee.com">万邦易嵌</a></p>
						</div>
					</div>
					<!-- End drawer scroll area -->
				</aside>
				<!-- End drawer -->

				<!-- Header -->
				<header class="app-layout-header">
					<nav class="navbar navbar-default">
						<div class="container-fluid">
							<div class="navbar-header">
								<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#header-navbar-collapse"
								 aria-expanded="false">
									<span class="sr-only">Toggle navigation</span>
									<span class="icon-bar"></span>
									<span class="icon-bar"></span>
									<span class="icon-bar"></span>
								</button>
								<button class="pull-left hidden-lg hidden-md navbar-toggle" type="button" data-toggle="layout" data-action="sidebar_toggle">
									<span class="sr-only">Toggle drawer</span>
									<span class="icon-bar"></span>
									<span class="icon-bar"></span>
									<span class="icon-bar"></span>
								</button>

							</div>

							<div class="collapse navbar-collapse" id="header-navbar-collapse">
								<!-- Header search form -->


								<ul id="main-menu" class="nav navbar-nav navbar-left">


								</ul>
								<!-- .navbar-left -->

								<ul class="nav navbar-nav navbar-right navbar-toolbar hidden-sm hidden-xs">




									<li class="dropdown dropdown-profile">
										<a href="javascript:void(0)" data-toggle="dropdown">
											<span class="m-r-sm">John Doe <span class="caret"></span></span>
											<img class="img-avatar img-avatar-48" src="assets/img/avatars/avatar3.jpg" alt="User profile pic" />
										</a>
										<ul class="dropdown-menu dropdown-menu-right">


											<li>
												<a href="login.html">退出</a>
											</li>
										</ul>
									</li>
								</ul>
								<!-- .navbar-right -->
							</div>
						</div>
						<!-- .container-fluid -->
					</nav>
					<!-- .navbar-default -->
				</header>
				<!-- End header -->

				<main class="app-layout-content">

					<!-- Page Content -->
					<div class="container-fluid p-y-md">
						<!-- Dynamic Table Full -->
						<div class="card">
							<div class="card-header">
								<h4>进度监控</h4>
							</div>
							<div class="card-block row">
								<!-- DataTables init on table by adding .js-dataTable-full class, functionality initialized in js/pages/base_tables_datatables.js -->
								<div class="dropdown col-md-4">
									选择考试：
									<button class="btn btn-default dropdown-toggle " type="button" id="dropdownMenu1" data-toggle="dropdown"
									 aria-haspopup="true" aria-expanded="true">
										<span class="btn-examNm">考试名称</span>
										<span class="caret"></span>
									</button>
									<ul class="dropdown-menu dropdown-examNm" id="dropdown-examNm" aria-labelledby="dropdownMenu1">

									</ul>
								</div>
								<div class="dropdown col-md-4">
									选择科目：
									<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown"
									 aria-haspopup="true" aria-expanded="true">
										<span class="btn-subNm">科目名称</span>
										<span class="caret"></span>
									</button>
									<ul class="dropdown-menu dropdown-subNm" id="dropdown-subNm" aria-labelledby="dropdownMenu1">

									</ul>
								</div>
								<div class="dropdown col-md-4">

								</div>

							</div>
							<!-- .card-block -->
						</div>
						<!-- .card -->
						<!-- End Dynamic Table Full -->
						<div id="card-body" class="parent-body">
							<!-- Dynamic Table Simple -->

						</div>
						<!-- .card -->
						<!-- End Dynamic Table Simple -->
					</div>
					<!-- .container-fluid -->
					<!-- End Page Content -->

				</main>

			</div>
			<!-- .app-layout-container -->
		</div>

		<!-- .app-layout-canvas -->

		<!-- Apps Modal -->
		<!-- Opens from the button in the header -->
		<div id="apps-modal" class="modal fade" tabindex="-1" role="dialog">
			<div class="modal-sm modal-dialog modal-dialog-top">
				<div class="modal-content">
					<!-- Apps card -->
					<div class="card m-b-0">
						<div class="card-header bg-app bg-inverse">
							<h4>Apps</h4>
							<ul class="card-actions">
								<li>
									<button data-dismiss="modal" type="button"><i class="ion-close"></i></button>
								</li>
							</ul>
						</div>
						<div class="card-block">
							<div class="row text-center">
								<div class="col-xs-6">
									<a class="card card-block m-b-0 bg-app-secondary bg-inverse" href="index.html">
										<i class="ion-speedometer fa-4x"></i>
										<p>Admin</p>
									</a>
								</div>
								<div class="col-xs-6">
									<a class="card card-block m-b-0 bg-app-tertiary bg-inverse" href="frontend_home.html">
										<i class="ion-laptop fa-4x"></i>
										<p>Frontend</p>
									</a>
								</div>
							</div>
						</div>
						<!-- .card-block -->
					</div>
					<!-- End Apps card -->
				</div>
			</div>
		</div>
		<!-- End Apps Modal -->

		<div class="app-ui-mask-modal"></div>

		<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
		<script src="assets/js/core/jquery.min.js"></script>
		<script src="assets/js/core/bootstrap.min.js"></script>
		<script src="assets/js/core/jquery.slimscroll.min.js"></script>
		<script src="assets/js/core/jquery.scrollLock.min.js"></script>
		<script src="assets/js/core/jquery.placeholder.min.js"></script>
		<script src="assets/js/app.js"></script>
		<script src="assets/js/app-custom.js"></script>

		<!-- Page JS Plugins -->
		<script src="assets/js/plugins/datatables/jquery.dataTables.min.js"></script>

		<!-- Page JS Code -->
		<script src="assets/js/pages/base_tables_datatables.js"></script>

		<script>
			var examId = null;
			var examSubId = null;
			var schId = 1;
			var progressMap = null;//列表的各种详细信息
			var showTeaData = null;//记录添加阅卷人查询列表的信息
			var scoreType = 1;//当前打分类型
			var selectKey = null;//当前选择的 题号
			var examNm = null;
			var examSubNm = null;
			var teaId = 1;
			
			function strExamInfo(data) {
				var str = "";
				for (var i = 0; i < data.length; i++) {
					var exam = data[i];
					str += '		<li><a href="#" id="item-exam" data="' + data[i].examId + '">' + exam.examNm + '</a></li>';
				}
				$(".dropdown-examNm").html(str);
			}
			
			//选择考试的点击事件
			function examItemClick() {
				$("#dropdown-examNm").delegate("#item-exam", "click", function() {
					var text = $(this).text();
					$(".btn-examNm").text(text);
					examId = $(this).attr("data");
					examNm = $(this).text();
					getExamSubInfo($(this).attr("data"));
					sessionStorage.setItem("examId",examId);
					sessionStorage.setItem("examNm",examNm);
					if(examSubId!=null){
						console.log(examId)
						//if(isSubjectLeader(examId,examSubId,teaId)==true){
							console.log(examSubId)
						getTeaProgress(examId,examSubId);
					}
				});
			}
			//选择科目的点击事件
			function examSubItemClick() {
				$("#dropdown-subNm").delegate("#item-examSub", "click", function() {
					var text = $(this).text();
					//console.log(text)
					$(".btn-subNm").text(text);
					examSubId = $(this).attr("data");
					examSubNm = $(this).text();
					sessionStorage.setItem("examSubId",examSubId);
					sessionStorage.setItem("examSubNm",examSubNm);
					if(isSubjectLeader(examId,examSubId,teaId)==false){
						$(".parent-body").html("");
						return ;
					}
					//获取老师的进度信息
					if(examId!=null)
					getTeaProgress(examId, examSubId);
				});
			}
			//字符串-考试科目列表
			function strExamSubInfo(data) {
				var str = "";
				for (var i = 0; i < data.length; i++) {
					var exam = data[i];
					str += '		<li><a href="#" id="item-examSub" data="' + data[i].examSubId + '">' + exam.subNm + '</a></li>';
				}
				$(".dropdown-subNm").html(str);
				//获取老师的进度信息

			}

			//获取考试科目信息
			function getExamSubInfo(examId) {
				var url = 'http://localhost:6630/wanbangee/exam-score/progress/selectMSubjectByExamId/' + examId;

				var token = sessionStorage.getItem("token")
				$.ajax({
					type: "get", //请求方式
					async: true, //是否异步
					headers: {
						"token": token
					},
					url: url,
					crossDomain: true,
					contentType: "application/x-www-form-urlencoded",
					//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
					success: function(data) {
						//请求成功处理，和本地回调完全一样
						if (data.code == 1001) {
							strExamSubInfo(data.result);
						}
					},
				});
			}
			//添加阅卷人查询-公共部分
			function strChooseTeaPub(key){
				//console.log("========================="+key)
				var str = "";
                        str+='<div class="card">';
                            str+='<div class="card-header" style="float:left;">';
                                // str+='<div class="card-actions">';
                                //     str+='<div class="input-group">';
                                //    	 str+='<input class="form-control" type="search" id="search-input-sub" placeholder="通过科目查询" />';
                                //    	 str+='<span class="input-group-btn">';
                                //    		str+='<button class="btn" type="button"><i class="ion-ios-search-strong"></i></button>';
                                //    	 str+='</span>';
                                //     str+='</div>';
                                // str+='</div>';
                                str+='<div class="card-actions" style="float:left" >';
                                    str+='<div class="input-group">';
                                   	 str+='<input class="form-control" type="search" id="search-input-name" placeholder="通过姓名查询" />';
                                   	 str+='<span class="input-group-btn">';
                                   		str+='<button class="btn" type="button"><i class="ion-ios-search-strong"></i></button>';
                                   	 str+='</span>';
                                    str+='</div>';
                                str+='</div>';
                            str+='</div>';
                            str+='<div class="card-block">';
                                str+='<table class="table table-hover .table-condensed">';
                                    str+='<thead>';
                                        str+='<tr>';
                                            str+='<th ">';
                                                str+='<label class="css-input css-checkbox css-checkbox-default m-t-0 m-b-0">';
								str+='<input type="checkbox" id="check-all" name="check-all"><span></span>';
							str+='</label>';
                                            str+='</th>';
                                           str+=' <th ">执教科目</th>';
                                           str+=' <th >姓名</th>';
                                       str+=' </tr>';
                                    str+='</thead>';
                                    str+='<tbody id="choose-tea-body" data="'+key+'">';
                                       
                                    str+='</tbody>';
                                str+='</table>';
                            str+='</div>';
                            <!-- .card-block -->
                        str+='</div>';
				
				return str;
			}
			//添加阅卷人查询-老师详细信息
			function strChooseTea(data,key){
				var str = "";
				showTeaData = data;
				//console.log(key)
				var value = null;
				 $.each(progressMap,function(key1,values){
					if(key == key1){
						value = values;
					}
					
				  });
				var teas = value;
				for (var i = 0; i < data.length; i++) {
					str+='<tr>';
						str+='<td >';
						 var flag = false;
						for (var j = 0; j < teas.length; j++) {
							if(teas[j].teaId1 == data[i].teaId||teas[j].teaId2==data[i].teaId||teas[j].teaId==data[i].teaId){
								
								 str+='<label class="css-input css-checkbox css-checkbox-primary disabled">';
								str+='<input type="checkbox" id="row_1" name="row_1" class="check-item" disabled ><small>已经存在</small>';
								flag = true;
								break;
							}
							scoreType = teas[j].scoreType;
						}
						if(flag!=true){
							str+='<label class="css-input css-checkbox css-checkbox-primary ">';
							str+='<input type="checkbox" id="row_1" class="check-item" name="row_1" ><span></span>';
						}
					       
							
							str+='</label>';
					    str+='</td>';
						
					    str+='<td>';
					        
							var teanms = data[i].teaMajorSubNm;
							if(data[i].teaSubNm2!=null){
								teanms +=","+ data[i].teaSubNm2;
							
							}
							if(data[i].teaSubNm3!=null){
								teanms +=","+ data[i].teaSubNm3;
							}
							str+='<p class="font-500 m-b-1">'+teanms+'</p>';
					    str+='</td>';
						str+='<td >'+data[i].teaNm+'</td>';
					   
					str+='</tr>';
					
				}
				$("#choose-tea-body").html(str);
				
			}
			var flag = false;
			//全选按钮
			function allCheckTea(){
				$(".parent-body").delegate("#check-all","click",function(){
					var checkboxs = $(".check-item");
					for (var i = 0; i < checkboxs.length; i++) {
						if(flag==false){
							$(checkboxs[i]).prop("checked",true);
						}else{
							$(checkboxs[i]).prop("checked",false);
						}
						
					}
					flag = flag==false?true:false;
				});
			}
			//保存按钮
			function saveTea(){
				$(".parent-body").delegate("#btn-save","click",function(){
		
					var checkboxs = $(".check-item");
					var modal = $('#myModal');
					
					if(scoreType==1){
						for (var i = 0; i < checkboxs.length; i++) {
							if($(checkboxs[i]).prop("checked")==true){
								saveMExamMarkerOne(showTeaData[i]);
							}
						}
					}else{
						var array = new Array();
						var k = 0;
						for (var i = 0; i < checkboxs.length; i++) {
							if($(checkboxs[i]).prop("checked")==true){
								array[k] = showTeaData[i];
								k++;
							}
						}
						if(array.length % 2 != 0){
							alert("该题为双评类型，需选择两个人并且刚好为两个人");
							return ;
						}else{
							saveMExamMarkerTwo(array[0],array[1]);
						}
					}
					 getTeaProgress(examId, examSubId);
					 
					 location.reload();
					 return false;
				})
			}
			//单评添加
			function saveMExamMarkerOne(tea1){
				var data = null;
				 $.each(progressMap,function(key,values){
					if(selectKey==key){
						data = JSON.parse(JSON.stringify(values[0]));
						var date = new Date();
						var day = date.getDate();
						var month = date.getMonth() + 1;
						var year = date.getFullYear();
						if (day < 10) {
							day = "0" + day;
						}
						if (month < 10) {
							month = "0" + month;
						}
						data.addTime = year+month+day;
						data.allocationNum = 0;
						data.teaNm1 = tea1.teaNm;
						data.teaId1 = tea1.teaId;
						return ;
					}
					
				  });
				  
				var mExamMarker = data
				  var url = "http://localhost:6630/wanbangee/exam-score/progress/insertMExamMarker";
				  var token = sessionStorage.getItem("token")
				  $.ajax({
					 headers: {
						"token": token
					},
				  	type: "post", //请求方式
				  	async: true, //是否异步
				  	url: url,
			 	  	data: JSON.stringify(mExamMarker),
					contentType: "application/x-www-form-urlencoded",
				  	crossDomain: true,
				  	dataType: "json", //跨域json请求一定是jsonp
				  	//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
				  	success: function(data) {
				  		//请求成功处理，和本地回调完全一样
				  		if (data.code == 1001) {
				  			
				  			
				  			//strChooseTea(data.result,key);
				  		}
				  	},
				  });
			}
			//多评添加
			function saveMExamMarkerTwo(tea1,tea2){
				var data = null;
				 $.each(progressMap,function(key,values){
					if(selectKey==key){
						data = JSON.parse(JSON.stringify(values[0]));
						var date = new Date();
						var day = date.getDate();
						var month = date.getMonth() + 1;
						var year = date.getFullYear();
						if (day < 10) {
							day = "0" + day;
						}
						if (month < 10) {
							month = "0" + month;
						}
						data.addTime = year+month+day;
						data.allocationNum = 0;
						data.teaNm1 = tea1.teaNm;
						data.teaId1 = tea1.teaId;
						data.teaNm2 = tea2.teaNm;
						data.teaId2 = tea2.teaId;
						return ;
					}
					
				  });
				  	var mExamMarker = data
				    var url = "http://localhost:6630/wanbangee/exam-score/progress/insertMExamMarker";
					var token = sessionStorage.getItem("token");
				    $.ajax({
							headers: {
							"token": token
						},
				    	type: "post", //请求方式
				    	async: true, //是否异步
				    	url: url,
				    	data: JSON.stringify(mExamMarker),
						contentType: "application/x-www-form-urlencoded",
				    	crossDomain: true,
				    	dataType: "json", //跨域json请求一定是jsonp
				    	//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
				    	success: function(data) {
				    		//请求成功处理，和本地回调完全一样
				    		if (data.code == 1001) {
				    			console.log(data)
				    			
				    			//strChooseTea(data.result,key);
				    		}
				    	},
				    });

			}
			
			//添加阅卷人按钮 btn-add-examtea
			function addExamTea(){
				$(".parent-body").delegate(".btn-add-examtea","click",function(){
					if (schId!=null){
					var url = "http://localhost:6630/wanbangee/exam-score/progress/selectUTeacherBySchIdAndSubIdAndTeaNmLike?schId="+schId;
					var key = $(this).attr("data");
					var token = sessionStorage.getItem("token")
					selectKey = key;
						$.ajax({
							headers: {
								"token": token
							},
							type: "get", //请求方式
							async: true, //是否异步
							url: url,
							crossDomain: true,
							contentType: "application/x-www-form-urlencoded",
							//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
							success: function(data) {
								//请求成功处理，和本地回调完全一样
								if (data.code == 1001) {
									// console.log(data)
									strChooseTea(data.result,key);
								}
							},
						});
					}
					
					
				});
			}

			
			//获取老师的进度详细信息
			function getTeaProgress(examId, examSubId) {
				console.log(11)
				if (examId!=null&&examSubId!=null){
					
					var url = 'http://localhost:6630/wanbangee/exam-score/progress/selectProgressList/' + examId + '/' + examSubId;
					var token = sessionStorage.getItem("token")
					$.ajax({
						headers: {
							"token": token
						},
						type: "get", //请求方式
						async: false, //是否异步
						url: url,
						crossDomain: true,
						contentType: "application/x-www-form-urlencoded",
						//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
						success: function(data) {
							console.log(data)
							//请求成功处理，和本地回调完全一样
							if (data.code == 1001) {
								
								progressMap = data.result;
								strTeaProgress(data.result)
							}else{
								$(".parent-body").html("")
							}
						},
					});
				}
			}
			//字符串-进度列表
			function strTeaProgress(data) {
				var str = "";
				var alreadyNum = 0;
				var allNum = 0;
				console.log("字符串-进度列表")
				console.log(data)
				$.each(data, function(key, values) {
					var i = 0;
					str += '<div class="card">';
					str += '<div class="card-header row">';

					$(values).each(function() {

						//console.log(this);
						if (i == 0) {
							str += '<small class="col-md-1">题组：' + this.topicNo + '</small>';
							str += '<small class="col-md-2">分值：' + this.topicScore + '</small>';
							if (this.scoreType == 1) {
								str += '<small class="col-md-2">评阅模式：单评</small>';
							} else {
								str += '<small class="col-md-2">评阅模式：双评</small>';
							}
							if (this.allocationType == 1) {
								str += '<small class="col-md-2">阅卷量分配：平均分配</small>';
							} else {
								str += '<small class="col-md-2">阅卷量分配：自定义分配</small>';
							}
							str += '<small class="col-md-2">阅卷进度：</small>';

							var progress = this.alreadyExamNum / this.allocationNum;
							var strProgress = Number(progress * 100).toFixed();
							strProgress += "%";


							str += '<div class="progress col-md-3 progress-style " id="progress-' + key +
								'" style="padding-left:0px;padding-right:0px" >';

							str += '</div>';

							str += '</div>';

							str +=
								'<button type="button" class="btn btn-primary btn-add-teastyle btn-sm col-md-1 btn-add-examtea" data="'+key+'" data-toggle="modal" data-target="#myModal">';
							str += '添加阅卷人';
							str += '</button>';

							<!-- Modal -->
							str += '<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">';
							str += ' <div class="modal-dialog " role="document">';
							str += '<div class="modal-content">';
							str += ' <div class="modal-header">';
							str +=
								'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
							str += '<h4 class="modal-title" id="myModalLabel">选择阅卷人</h4>';
							str += '</div>';
							str += '<div class="modal-body choose-tea-'+key+'">';
							str += strChooseTeaPub(key);
							str += '</div>';
							str += '<div class="modal-footer">';
							str += '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>';
							str += '<button type="button" class="btn btn-primary" id="btn-save" data="'+key+'">保存</button>';
							str += '</div>';
							str += '</div>';
							str += '</div>';
							str += '</div>';

							str += '<div class="card-block">';
							str += '<table class="table table-hover ">';
							str += '<thead>';
							str += '<tr>';
							str += '<th class="text-center" style="width: 50px;"><small>阅卷人</small></th>';
							str += '<th style="width: 100px;">阅卷进度</th>';
							str += '<th class="hidden-xs w-15">完成度</th>';
							str += '<th class="text-center" style="width: 100px;">编辑</th>';
							str += '</tr>';
							str += '</thead>';
							str += '<tbody id="progressList-body-'+key+'">';
						}


						str += '<tr>';
						if (this.scoreType == 1) {
							str += '<td class="text-center">' + this.teaNm1 + '</td>';
						} else {
							str += '<td class="text-center">' + this.teaNm1 + ',' + this.teaNm2 + '</td>';
						}

						str += '<td>' + this.alreadyExamNum + '/' + this.allocationNum; + '</td>';
						var progress = this.alreadyExamNum / this.allocationNum;
						if(isNaN(progress)){
							str += '<td class="hidden-xs">0</td>';
						}else{
							str += '<td class="hidden-xs">' + progress + '</td>';
						}
						str += '<td class="text-center">';
						str += '<div class="btn-group">';
						//str +=
						//	'<button class="btn btn-xs btn-default btn-resolve" type="button" data-toggle="tooltip" data-key="'+key+'" data-id="'+this.markerId+'" title="Edit client"><i class="fa fa-minus-circle"></i>分解阅卷任务</button>';
						str += resolverModelAlert(key,this.markerId);
						
						
						
						str += '</div>';
						str += '</td>';
						str += '</tr>';

						i++;
					});
					str += '</tbody>';
					str += '</table>';
					str += '</div>';
					str += '</div>';

				});
				$("#card-body").html(str);

				$.each(data, function(key, values) {
					var str1 = "";
					var allNum = 0;
					var alreadyNum = 0;
					$(values).each(function() {
						allNum += Number(this.allocationNum);
						alreadyNum += Number(this.alreadyExamNum);
					});
					var strAllProgress = Number(alreadyNum / allNum * 100).toFixed();
					strAllProgress += "%";
					str1 += '<div class="progress-bar progress-bar-success " role="progressbar" aria-valuenow="' + alreadyNum +
						'" aria-valuemin="0"';
					str1 += 'aria-valuemax="100" style="width:' + strAllProgress + '">';
					str1 += strAllProgress;
					str1 += '</div>';
					$("#progress-" + key).html(str1);
				});
			}
/* 分解阅卷任务 */
			//分解阅卷任务按钮
			function btnResolveClick(){
				
				$(".parent-body").delegate(".btn-resolve", "click", function() {
					
					var key = $(this).attr("data-key");
					var markerId = $(this).attr("data-id");
					$.each(progressMap, function(key1, values) {
						if(key == key1){
							$(values).each(function () {
								if(this.markerId==markerId){
									
									
								}
							})
						}
					});
					
				});
			}
			
			//增加按钮的点击事件
			function addMathClick(){
				$(".parent-body").delegate(".btn-math-add", "click", function() {
					var val = $(this).next().val();
					var key = $(this).attr('data-key');
					var markerId = $(this).attr('data-id');
					
					var surplus = 0;
					$.each(progressMap, function(key1, values) {
						if(key == key1){
							$(values).each(function () {
								
								if(this.markerId==markerId){
									surplus = this.surplus;
									return ;
								}
							})
							return ;
						}
					});
					if (val==surplus){
						
					}else{
						val++;
						console.log(val)
						$(this).next().val(val);
						
					}
				});
				
			}
			
			//相减按钮的点击事件
			function lostMathClick(){
				$(".parent-body").delegate(".btn-math-lost", "click", function() {
					var val = $(this).prev().val();
					var key = $(this).attr('data-key');
					var markerId = $(this).attr('data-id');
					
					var surplus = 0;
					if (val==0){
						
					}else{
						val--;
						
						$(this).prev().val(val);
						
					}
				});
				
			}
			
			//分解阅卷任务的点击事件
			function saveResolverClick(){
				$(".parent-body").delegate("#btn-save-resolver", "click", function() {
					var key = $(this).attr("data-key")
					var oldMarkerId = $(this).attr("data-id");
					
					var radios = $(".radio"+oldMarkerId+"");
					var data = {};
					console.log(oldMarkerId)
					for (var i = 0; i < radios.length; i++) {
						
						if($(radios[i]).prop("checked")==true){
							data.newMarkerId = $(radios[i]).attr("data-id");;
							data.topicCount = $(".input"+oldMarkerId+"").val();
							data.oldMarkerId = oldMarkerId;
							$.each(progressMap, function(key1, values) {
								if(key == key1){
									$(values).each(function () {
											data.topicNo = this.topicNo;
											data.examId = this.examId;
											data.examSubId = this.examSubId;
											return ;
										
									})
									return ;
								}
							});
						}
					}
					console.log(data)
					var url = "http://localhost:6630/wanbangee/exam-score/progress/ExamResolve";
					var token = sessionStorage.getItem("token");
					$.ajax({
						type: "post", //请求方式
						headers: {
							"token": token
						},
						async: true, //是否异步
						url: url,
						data: data,
						crossDomain: true,
						contentType: "application/x-www-form-urlencoded",
						//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
						success: function(data) {
							console.log(data)
							//请求成功处理，和本地回调完全一样
							if (data.code == 1001) {
							
							}
						},
					});
					location.reload();
					
				});
			}
			
			//分解阅卷任务弹出窗
			function resolverModelAlert(key,markerId){		
				var str = "";
				str +=
					'<button type="button" class="btn btn-primary btn-sm btn-resolve" data-key="'+key+'" data-id="'+markerId+'"  data-toggle="modal" data-target=".myModal'+markerId+'">';
				str += '分解阅卷任务';
				str += '</button>';
				
				str += '<div class="modal fade myModal'+markerId+'" id="" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">';
				str += ' <div class="modal-dialog " role="document">';
				str += '<div class="modal-content">';
				str += ' <div class="modal-header">';
				str +=
					'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
				str += '<h4 class="modal-title" id="myModalLabel1">选择组</h4>';
				str += '</div>';
				str += '<div class="modal-body ">';
				
						str+='<div class="card">';
				            str+='<div class="" style="">';
				               // str+='<div class="card-actions" style="float:left" >';
				                    str+='<div class="row ">';
				
				$.each(progressMap, function(key1, values) {
					if(key == key1){
						$(values).each(function () {
							
							if(this.markerId==markerId){
								this.surplus = this.allocationNum-this.alreadyExamNum;
								str+='<label data="'+(this.allocationNum-this.alreadyExamNum)+'">剩余数量：'+(this.allocationNum-this.alreadyExamNum)+'</label>';
								return ;
							}
						})
						return ;
					}
				});
				
				
										str+='<button class="btn btn-default btn-sm btn-math-add" data-id="'+markerId+'" data-key="'+key+'"><i class="fa fa-plus-circle fa-2x"></i></button>';
										str+='<input type="text" class="input'+markerId+'" value="0" style="width:50px;"  placeholder="">';
										str+='<button class="btn btn-default btn-sm btn-math-lost " data-id="'+markerId+'" data-key="'+key+'"><i class="fa fa-minus-circle fa-2x"></i></button>';
				                    str+='</div>';
				                //str+='</div>';
				            str+='</div>';
				            str+='<div class="">';
								str+='<div class="form-group">';
                                                str+='<label class="col-xs-12">选择老师</label>';
                                                str+='<div class="col-xs-12">';
												
												str += resolverModelTeaInfo(key,markerId);
                                                    
                                                str+='</div>';
                                           str+=' </div>';
				            str+='</div>';
				            <!-- .card-block -->
				        str+='</div>';
				
				
				
				
				
				str += '</div>';
				str += '<div class="modal-footer">';
				str += '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>';
				str += '<button type="button" class="btn btn-primary" id="btn-save-resolver" data-key="'+key+'" data-id="'+markerId+'">保存</button>';
				str += '</div>';
				str += '</div>';
				str += '</div>';
				str += '</div>';
				return str;
			}

			//分解阅卷任务弹出窗的老师信息
			function resolverModelTeaInfo(key,oldMarkerId){
				var str = "";
				$.each(progressMap, function(key1, values) {
					
					if(key == key1){
						$(values).each(function () {
							if(this.markerId!=oldMarkerId){
								str+='<label class="radio-inline" for="example-inline-radio1">';
								
								if(this.scoreType==1)
									str+='<input type="radio" class="radio'+oldMarkerId+'" id="example-inline-radio1" name="example-inline-radios" data-key="'+key+'" data-id="'+this.markerId+'" />'+this.teaNm1;
								else{
									str+='<input type="radio" class="radio'+oldMarkerId+'" id="example-inline-radio1" name="example-inline-radios" data-key="'+key+'" data-id="'+this.markerId+'" />'+this.teaNm1+","+this.teaNm2;
								}
								str+='</label>';
								return ;
							}
							
						})
						return ;
					}
				});
				return str;
			}

			//根据学校id获取当前的考试名称
			function getExamInfo() {
				var date = new Date();
				var day = date.getDate();
				var month = date.getMonth() + 1;
				var year = date.getFullYear();
				if (day < 10) {
					day = "0" + day;
				}
				if (month < 10) {
					month = "0" + month;
				}
				var url = "http://localhost:6630/wanbangee/exam-score/progress/selectExamId/"+schId+"/" + year + month + day;
				var token = sessionStorage.getItem("token")
				$.ajax({
					headers: {
						"token": token
					},
					type: "get", //请求方式
					async: true, //是否异步
					url: url,
					crossDomain: true,
					contentType: "application/x-www-form-urlencoded",
					//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
					success: function(data) {
						if (data.code == 1001) {
							strExamInfo(data.result);
							
						}
					},
				});
				
				

			}
			
			function init(){
				examNm = sessionStorage.getItem("examNm");
				examSubNm = sessionStorage.getItem("examSubNm");
				examId = sessionStorage.getItem("examId");
				examSubId = sessionStorage.getItem("examSubId");
				if(examNm!=null&&examSubNm!=null){
					$(".btn-examNm").text(examNm);
					$(".btn-subNm").text(examSubNm)
					console.log(isSubjectLeader(examId,examSubId,teaId))
					if(isSubjectLeader(examId,examSubId,teaId)==true){
						console.log(11)
						getTeaProgress(examId,examSubId);
						if(examId!=null)
						getExamSubInfo(examId)
					}
						
					
					
				}
				
			}
			function getTeaInfo(){
				var token = sessionStorage.getItem("token");
			}
			
			//是否为学科负责人
			function isSubjectLeader(examId,examSubId,teaId){
				var url = "http://localhost:6630/wanbangee/exam-score/quality/selectIsPrincipalTea/"+examId+"/"+examSubId+"/"+teaId;
				var token = sessionStorage.getItem("token")
				var flag = false;
				$.ajax({
					headers: {
						"token": token
					},
					type: "get", //请求方式
					async: false, //是否异步
					url: url,
					crossDomain: true,
					contentType: "application/x-www-form-urlencoded",
					//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
					success: function(data) {
						console.log(22)
						console.log(data)
						if (data.code == 1001) {
							flag = true;
						}else{
							flag = false;
						}
					},
				});
				return flag;
			}
			
			$(function() {
				getExamInfo();
				//选中考试的点击事件
				examItemClick();
				//选中科目的点击事件
				examSubItemClick();
				//给添加阅卷人赋予点击事件
				addExamTea();
				//全选按钮
				allCheckTea();
				//保存按钮
				saveTea();
				//分解任务的点击按钮
				btnResolveClick();
				//增加按钮的点击事件
				addMathClick();
				//相减按钮的点击事件
				lostMathClick();
				//分解阅卷任务的点击事件
				saveResolverClick();
				
				
				//初始化方法
				init();
				

			});
		</script>
		<style>
			.btn-add-teastyle {
				margin-left: 5%;
			}
		</style>

	</body>

</html>
